Skip to content

Conversation

@koki-develop
Copy link
Owner

Previously, the Gat struct cached the auto-detected lexer in the lexer field after the first Print call, causing subsequent calls to use the wrong lexer for different file types.

This change:

  • Renames the lexer field to explicitLexer to clarify it only holds user-specified lexers
  • Introduces a local lexer variable in Print method that is resolved per call
  • Ensures auto-detected lexers are not written back to the struct field

This fixes the issue where processing multiple files with different types would incorrectly use the first file's lexer for all subsequent files.

🤖 Generated with Claude Code

Previously, the Gat struct cached the auto-detected lexer in the lexer field after the first Print call, causing subsequent calls to use the wrong lexer for different file types.

This change:
- Renames the lexer field to explicitLexer to clarify it only holds user-specified lexers
- Introduces a local lexer variable in Print method that is resolved per call
- Ensures auto-detected lexers are not written back to the struct field

This fixes the issue where processing multiple files with different types would incorrectly use the first file's lexer for all subsequent files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@koki-develop koki-develop requested a review from Copilot October 4, 2025 07:12
@koki-develop koki-develop self-assigned this Oct 4, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fix ensures lexer is resolved per Print call rather than cached globally, preventing reuse of the first detected lexer across different file types.

  • Rename cached field to explicitLexer to clarify semantics.
  • Introduce per-call local lexer resolution instead of mutating struct.
  • Avoid persisting auto-detected lexers, fixing cross-file highlighting errors.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

NoResize bool
}

type Gat struct {
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a clarifying comment above explicitLexer (e.g. // explicitLexer holds only a user-specified lexer; auto-detected lexers are resolved per Print call and never cached) to prevent future regressions or reintroduction of caching.

Suggested change
type Gat struct {
type Gat struct {
// explicitLexer holds only a user-specified lexer; auto-detected lexers are resolved per Print call and never cached.

Copilot uses AI. Check for mistakes.
@koki-develop koki-develop merged commit 496638c into main Oct 4, 2025
4 checks passed
@koki-develop koki-develop deleted the fix/lexer-per-file branch October 4, 2025 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants